import java.awt.DisplayMode;
import java.awt.GraphicsDevice;
import java.awt.GraphicsEnvironment;
import java.awt.Window;

import javax.swing.JFrame;


public class Screen {
	
	private GraphicsDevice vc;
	
	public Screen() {
		GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
		vc = ge.getDefaultScreenDevice();
	}
	
	public void setFullScreen(DisplayMode dm, JFrame frame){
		frame.setUndecorated(true);
		frame.setResizable(false);
		vc.setFullScreenWindow(frame);
		
		if (dm != null && vc.isDisplayChangeSupported()) {
			vc.setDisplayMode(dm);
		}
	}
	
	public Window getFullScreenWindow() {
		return vc.getFullScreenWindow();
	}
	
	public void restoreScreen() {
		Window w = getFullScreenWindow();
		if (w != null){
			w.dispose();
		}
		vc.setFullScreenWindow(null);
	}
}
